package com.example.rxjavaretrofit;

import android.os.Bundle;

import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.google.android.material.snackbar.Snackbar;

import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;

import android.util.Log;
import android.view.View;
import android.view.Menu;
import android.view.MenuItem;

import java.util.List;

import bean.GoodsPriceMode;
import bean.ManagerMode;
import http.ApiUrl;
import http.BaseObserver;
import http.RequestUtils;
import http.RetrofitUtils;
import http.StringObserver;
import io.reactivex.Observer;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers;
import okhttp3.ResponseBody;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

//        RequestUtils.getGoodsPrice("ae8b5338effa4bb1889f195ed37f7d51", "WH0003", new BaseObserver<GoodsPriceMode>(this) {
//            @Override
//            public void onSuccess(GoodsPriceMode goodsPriceMode) {
//                List<GoodsPriceMode.GoodsListBean> list = goodsPriceMode.getGoodsList();
//                Log.e("wh", list.get(0).getPrice());
//
//            }
//
//            @Override
//            public void onFailure(Throwable e, String errorMsg) {
//                Log.e("wh", errorMsg);
//            }
//        });
//
//        RequestUtils.getManagerPhone("ae8b5338effa4bb1889f195ed37f7d51", "WH0003", new BaseObserver<ManagerMode>(this) {
//            @Override
//            public void onSuccess(ManagerMode mode) {
//                Log.e("wh", mode.getName());
//            }
//
//            @Override
//            public void onFailure(Throwable e, String errorMsg) {
//                Log.e("wh", errorMsg);
//            }
//        });


        //这个是直接返回的json 字符串格式的（）需要修改Retrofit配置 .addConverterFactory(ScalarsConverterFactory.create())
        RequestUtils.getManagerPhone1("e90de2229c514b72884fdd0a68839668", "WH0003", new StringObserver(this) {
            @Override
            public void onSuccess(String s) {
                Log.e("wh",s);
            }

            @Override
            public void onFailure(Throwable e, String errorMsg) {
                Log.e("wh",errorMsg);
            }


        });


    }


}
